#!/bin/bash

db_date=$2
echo $db_date
db_name=village_unemployee

import_data() {
/home/software/sqoop-1.4.7/bin/sqoop import \
--connect jdbc:mysql://192.168.1.90:3306/$db_name \
--username changyuan \
--password tecsunBD@2020 \
--target-dir /origin_data/db/$1/$db_date \
--delete-target-dir \
--num-mappers 1 \
--null-string '\\N' \
--null-non-string '\\N' \
--fields-terminated-by ";" \
--query "$2"' and $CONDITIONS;'
}

import_help_people(){
  import_data "help_people" "select * from help_people where 1=1"
}

import_unemploy_person(){
  import_data "unemploy_person" "select * from unemploy_person where 1=1"
}


case $1 in
   "all")
   import_help_people
   import_unemploy_person
  ;;
esac